<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<jsp:useBean id="user" class="entity.User" scope="session"/>
<jsp:useBean id="appointment" class="entity.Appointment" scope="request"/>
<jsp:useBean id="players" class="java.util.ArrayList" scope="request"/>

<html>
	<head>
		<title>Recreation Manager - Detalji o meču</title>
		<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
		<link rel="stylesheet" type="text/css" href="theme.css">
		<script type="text/javascript" src="scripts/linkfader.js"></script>
	</head>
	<c:if test="${user.userId==null}">
		<c:redirect url="./main.jsp" />
	</c:if>
	<body>
	<center>
	<c:import url="./header.jsp"></c:import>
	<table class="mainTable">
		<tr>
			<td width="200px" valign="top">
				<c:import url="./menu.jsp"></c:import>
			</td>			
			<td valign="top">
			<!-- itt kezdodik -->
				<table class="list">
				<tr>
					<td colspan="2"><h2>Detalji o meču</h2></td>
				</tr>
				<tr>
					<td align="left">Naziv:</td>
					<td align="left">${appointment.footballMatch.name}</td>
				</tr>
				<tr>
					<td align="left">Lokacija:</td>
					<td align="left">${appointment.location}</td>
				</tr>
				<tr>
					<td align="left">Termin: </td>
					<td align="left">
						<fmt:formatDate value="${appointment.date}" pattern="dd.MM.yyyy" />
						od: <fmt:formatDate value="${appointment.from}" pattern="hh:mm"/>
					    do: <fmt:formatDate value="${appointment.to}" pattern="hh:mm"/>
					</td>
				</tr>
				<tr>
					<td align="left">Rezultat:</td>
					<td align="left">${appointment.footballMatch.goalHome}:${appointment.footballMatch.goalGuest}</td>
				</tr>
				<tr>
					<td align="left">MVP:</td>
					<td align="left">${appointment.footballMatch.mvp.firstName} ${appointment.footballMatch.mvp.lastName}</td>
				</tr>
				<tr>
					<td colspan="2">&nbsp;</td>
				</tr>
			</table>	
			<table class="list">
				<thead>
				<tr>
					<td colspan="2"><h3>Strelci:</h3></td>
				</tr>
				<tr>
					<th width="50%">Igrač</th>
					<th width="50%">Golovi</th>
				</tr>
				</thead>
				<tbody>
				<c:forEach items="${players}" var="pl">
						<tr>
							<c:if test="${pl.goal>0}">
								<td>${pl.user.firstName} ${pl.user.lastName}</td>
								<td>${pl.goal}</td>
							</c:if>
						</tr>
					</c:forEach>
				<tr>
					<td colspan="2">&nbsp;</td>
				</tr>
				</tbody>
			</table>			
			<table class="list">
				<thead>
				<tr>
					<td colspan="2"><h3>Timovi</h3></td>
				</tr>			
				<tr>
					<th width="50%">Domaćin</th>
					<th width="50%">Gost</th>
				</tr>
				</thead>
				<tbody>
				<tr>
					<td width="50%">
						<table class="list">
							<c:forEach items="${players}" var="pl">
									<tr>
										<c:if test="${pl.team=='H'}">
											<td>${pl.user.firstName} ${pl.user.lastName}</td>
										</c:if>
									</tr>
								</c:forEach>
						</table>
					</td>
					<td width="50%">
					<table class="list">
						<c:forEach items="${players}" var="pl">
								<tr>
									<c:if test="${pl.team=='G'}">
										<td>${pl.user.firstName} ${pl.user.lastName}</td>
									</c:if>
								</tr>
						</c:forEach>
					</table>
					</td>
				</tr>
				</tbody>
				</table>
			<!-- itt vegzodik -->
			</td>
		</tr>
	</table>		
	</center>
	</body>	
</html>